#include "wifi_init.h"



void WIFI_connect(void)
{
    if(!WiFi.isConnected())
    {
    while(WiFi.waitForConnectResult()!=WL_CONNECTED)
    {
        WiFi.reconnect();
        Serial.println("reconnecting..");
        delay(5000);
    }
    Serial.printf("\nWiFi connected ");
    Serial.printf("IP address: ");
    Serial.println(WiFi.localIP());
    Serial.printf("MAC:%s\n",mac);
    }
}


void WIFI_init(void)
{
    // char ho
    strcpy(host_name+strlen(host_name),mac);
    WiFi.setHostname(host_name);
    WiFi.begin(SSID,PASSWD);
    WiFi.setAutoConnect(true);
    WiFi.setAutoReconnect(true);
    while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
    }
    // WIFI_connect();
}